package com.kj.platformlogistics.home.activity;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.widget.TextView;

import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.kj.platformlogistics.R;
import com.kj.platformlogistics.base.BaseActivity;
import com.kj.platformlogistics.home.adapter.TraceAdapter;
import com.kj.platformlogistics.home.adapter.WaitSolicilationDetailAdapter;
import com.kj.platformlogistics.home.model.SolicilationedModel;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

public class SendingDetailActivity extends BaseActivity {
    private RecyclerView rcCommon,rcTrack;
    private WaitSolicilationDetailAdapter adapter;
    private TraceAdapter traceAdapter;
    private SolicilationedModel.ResultDTO.PageDTO model;
    private TextView tvPostName,tvPostAddress,tvReceiveName,tvReceiveAddress,tvNumber,
            tvOrderNumber,tvPayType,tvOrderCreateTime;

    public static void actionStart(Context context, SolicilationedModel.ResultDTO.PageDTO model) {
        Intent intent = new Intent(context, SendingDetailActivity.class);
        intent.putExtra("model",(Serializable) model);
        context.startActivity(intent);
    }

    @Override
    protected void init(Bundle savedInstanceState) {
        setAndroidNativeLightStatusBar(true);
    }

    @Override
    protected int setLayoutResourceID() {
        return R.layout.activity_sending_detail;
    }

    @Override
    protected void initView() {
        setTitleText("订单详情");
        model=(SolicilationedModel.ResultDTO.PageDTO)getIntent().getSerializableExtra("model");
        rcCommon=findViewById(R.id.rcCommon);
        tvPostName=findViewById(R.id.tvPostName);
        rcTrack=findViewById(R.id.rcTrack);
        tvReceiveName=findViewById(R.id.tvReceiveName);
        tvPayType=findViewById(R.id.tvPayType);
        tvReceiveAddress=findViewById(R.id.tvReceiveAddress);
        tvPostAddress=findViewById(R.id.tvPostAddress);
        tvOrderNumber=findViewById(R.id.tvOrderNumber);
        tvOrderCreateTime=findViewById(R.id.tvOrderCreateTime);
        tvNumber=findViewById(R.id.tvNumber);

        if (model!=null){
            setView();
        }
    }
    public void setView(){
        tvPostName.setText(model.getMailName());
        tvPostAddress.setText(model.getMailAddress());
        tvReceiveName.setText(model.getReceiveName());
        tvReceiveAddress.setText(model.getReceiveAddress());
        tvNumber.setText(model.getNum()+"件");
        tvPayType.setText(model.getPayWay());
        tvOrderCreateTime.setText(model.getCreateTime());
        tvOrderNumber.setText(model.getWaybillNumber());
        if (model.getOrderDetailList().size()>0){
            adapter=new WaitSolicilationDetailAdapter(model.getOrderDetailList());
            rcCommon.setAdapter(adapter);
            rcCommon.setLayoutManager(new LinearLayoutManager(this));
        }
        if (model.getLogisticsStatusList().size()>0){
            traceAdapter=new TraceAdapter(this,model.getLogisticsStatusList());
            rcTrack.setAdapter(traceAdapter);
            rcTrack.setLayoutManager(new LinearLayoutManager(this));
        }
    }

    @Override
    protected void initData() {

    }

    /**
     * 获取要使用的标题栏样式(此函数由子类重写)
     *
     * @return
     */
    @Override
    protected int getTitleBarType() {
        return 0;
    }
}
